Disease detection on PlantDoc using YOLOv7
To train YOLOv7 on the PlantDoc dataset, we take the following steps:
- Install YOLOv7 dependencies
- Load the PlantDoc dataset from Roboflow in YOLOv7 format
- Run YOLOv7 training
- Evaluate YOLOv7 performance
Install dependencies
%%capture
! git clone https://github.com/WongKinYiu/yolov7
%cd yolov7
! pip install -r requirements.txt
Download the PlantDoc dataset in YOLOv7 format
Next, we use the Python API provided by Roboflow to download the PlantDoc dataset, api_key should be replaced by your api key gotten from Roboflow.
%%capture
! pip install roboflow
from roboflow import Roboflow
rf = Roboflow(api_key="YOUR API KEY")
project = rf.workspace("joseph-nelson").project("plantdoc")
dataset = project.version(1).download("yolov7")
Start Training
First, download the YOLOv7 model pre-trained on the COCO dataset
%%capture
! wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7_training.pt
Then, custom training on the PlantDoc dataset, we pass a number of arguments:
- batch: batch size
- epochs: the number of training epochs
- data: the PlantDoc dataset is saved in dataset.location folder
- weights: the COCO pre-trained YOLOv7 weights
- device: setting GPU
- img-size: image size. Here, the images of the PlantDoc dataset have size (416,416)
> Note: If hit error, please see the error resolve
! python train.py --batch 16 --epochs 100 --data {dataset.location}/data.yaml --weights 'yolov7_training.pt' --device 0 --img-size 416
YOLOR 🚀 v0.1-116-g8c0bf3f torch 1.13.1+cu117 CUDA:0 (NVIDIA A100-SXM4-80GB, 81069.75MB)
Namespace(weights='yolov7_training.pt', cfg='', data='/notebooks/yolov7/PlantDoc-1/data.yaml', hyp='data/hyp.scratch.p5.yaml', epochs=100, batch_size=16, img_size=[416, 416], rect=False, resume=False, nosave=False, notest=False, noautoanchor=False, evolve=False, bucket='', cache_images=False, image_weights=False, device='0', multi_scale=False, single_cls=False, adam=False, sync_bn=False, local_rank=-1, workers=8, project='runs/train', entity=None, name='exp', exist_ok=False, quad=False, linear_lr=False, label_smoothing=0.0, upload_dataset=False, bbox_interval=-1, save_period=-1, artifact_alias='latest', freeze=[0], v5_metric=False, world_size=1, global_rank=-1, save_dir='runs/train/exp6', total_batch_size=16)
tensorboard: Start with 'tensorboard --logdir runs/train', view at http://localhost:6006/
hyperparameters: lr0=0.01, lrf=0.1, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.3, cls_pw=1.0, obj=0.7, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.2, scale=0.9, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.15, copy_paste=0.0, paste_in=0.15, loss_ota=1
wandb: Install Weights & Biases for YOLOR logging with 'pip install wandb' (recommended)
Overriding model.yaml nc=80 with nc=30
from n params module arguments
0 -1 1 928 models.common.Conv [3, 32, 3, 1]
1 -1 1 18560 models.common.Conv [32, 64, 3, 2]
2 -1 1 36992 models.common.Conv [64, 64, 3, 1]
3 -1 1 73984 models.common.Conv [64, 128, 3, 2]
4 -1 1 8320 models.common.Conv [128, 64, 1, 1]
5 -2 1 8320 models.common.Conv [128, 64, 1, 1]
6 -1 1 36992 models.common.Conv [64, 64, 3, 1]
7 -1 1 36992 models.common.Conv [64, 64, 3, 1]
8 -1 1 36992 models.common.Conv [64, 64, 3, 1]
9 -1 1 36992 models.common.Conv [64, 64, 3, 1]
10 [-1, -3, -5, -6] 1 0 models.common.Concat [1]
11 -1 1 66048 models.common.Conv [256, 256, 1, 1]
12 -1 1 0 models.common.MP []
13 -1 1 33024 models.common.Conv [256, 128, 1, 1]
14 -3 1 33024 models.common.Conv [256, 128, 1, 1]
15 -1 1 147712 models.common.Conv [128, 128, 3, 2]
16 [-1, -3] 1 0 models.common.Concat [1]
17 -1 1 33024 models.common.Conv [256, 128, 1, 1]
18 -2 1 33024 models.common.Conv [256, 128, 1, 1]
19 -1 1 147712 models.common.Conv [128, 128, 3, 1]
20 -1 1 147712 models.common.Conv [128, 128, 3, 1]
21 -1 1 147712 models.common.Conv [128, 128, 3, 1]
22 -1 1 147712 models.common.Conv [128, 128, 3, 1]
23 [-1, -3, -5, -6] 1 0 models.common.Concat [1]
24 -1 1 263168 models.common.Conv [512, 512, 1, 1]
25 -1 1 0 models.common.MP []
26 -1 1 131584 models.common.Conv [512, 256, 1, 1]
27 -3 1 131584 models.common.Conv [512, 256, 1, 1]
28 -1 1 590336 models.common.Conv [256, 256, 3, 2]
29 [-1, -3] 1 0 models.common.Concat [1]
30 -1 1 131584 models.common.Conv [512, 256, 1, 1]
31 -2 1 131584 models.common.Conv [512, 256, 1, 1]
32 -1 1 590336 models.common.Conv [256, 256, 3, 1]
33 -1 1 590336 models.common.Conv [256, 256, 3, 1]
34 -1 1 590336 models.common.Conv [256, 256, 3, 1]
35 -1 1 590336 models.common.Conv [256, 256, 3, 1]
36 [-1, -3, -5, -6] 1 0 models.common.Concat [1]
37 -1 1 1050624 models.common.Conv [1024, 1024, 1, 1]
38 -1 1 0 models.common.MP []
39 -1 1 525312 models.common.Conv [1024, 512, 1, 1]
40 -3 1 525312 models.common.Conv [1024, 512, 1, 1]
41 -1 1 2360320 models.common.Conv [512, 512, 3, 2]
42 [-1, -3] 1 0 models.common.Concat [1]
43 -1 1 262656 models.common.Conv [1024, 256, 1, 1]
44 -2 1 262656 models.common.Conv [1024, 256, 1, 1]
45 -1 1 590336 models.common.Conv [256, 256, 3, 1]
46 -1 1 590336 models.common.Conv [256, 256, 3, 1]
47 -1 1 590336 models.common.Conv [256, 256, 3, 1]
48 -1 1 590336 models.common.Conv [256, 256, 3, 1]
49 [-1, -3, -5, -6] 1 0 models.common.Concat [1]
50 -1 1 1050624 models.common.Conv [1024, 1024, 1, 1]
51 -1 1 7609344 models.common.SPPCSPC [1024, 512, 1]
52 -1 1 131584 models.common.Conv [512, 256, 1, 1]
53 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
54 37 1 262656 models.common.Conv [1024, 256, 1, 1]
55 [-1, -2] 1 0 models.common.Concat [1]
56 -1 1 131584 models.common.Conv [512, 256, 1, 1]
57 -2 1 131584 models.common.Conv [512, 256, 1, 1]
58 -1 1 295168 models.common.Conv [256, 128, 3, 1]
59 -1 1 147712 models.common.Conv [128, 128, 3, 1]
60 -1 1 147712 models.common.Conv [128, 128, 3, 1]
61 -1 1 147712 models.common.Conv [128, 128, 3, 1]
62[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1]
63 -1 1 262656 models.common.Conv [1024, 256, 1, 1]
64 -1 1 33024 models.common.Conv [256, 128, 1, 1]
65 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
66 24 1 65792 models.common.Conv [512, 128, 1, 1]
67 [-1, -2] 1 0 models.common.Concat [1]
68 -1 1 33024 models.common.Conv [256, 128, 1, 1]
69 -2 1 33024 models.common.Conv [256, 128, 1, 1]
70 -1 1 73856 models.common.Conv [128, 64, 3, 1]
71 -1 1 36992 models.common.Conv [64, 64, 3, 1]
72 -1 1 36992 models.common.Conv [64, 64, 3, 1]
73 -1 1 36992 models.common.Conv [64, 64, 3, 1]
74[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1]
75 -1 1 65792 models.common.Conv [512, 128, 1, 1]
76 -1 1 0 models.common.MP []
77 -1 1 16640 models.common.Conv [128, 128, 1, 1]
78 -3 1 16640 models.common.Conv [128, 128, 1, 1]
79 -1 1 147712 models.common.Conv [128, 128, 3, 2]
80 [-1, -3, 63] 1 0 models.common.Concat [1]
81 -1 1 131584 models.common.Conv [512, 256, 1, 1]
82 -2 1 131584 models.common.Conv [512, 256, 1, 1]
83 -1 1 295168 models.common.Conv [256, 128, 3, 1]
84 -1 1 147712 models.common.Conv [128, 128, 3, 1]
85 -1 1 147712 models.common.Conv [128, 128, 3, 1]
86 -1 1 147712 models.common.Conv [128, 128, 3, 1]
87[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1]
88 -1 1 262656 models.common.Conv [1024, 256, 1, 1]
89 -1 1 0 models.common.MP []
90 -1 1 66048 models.common.Conv [256, 256, 1, 1]
91 -3 1 66048 models.common.Conv [256, 256, 1, 1]
92 -1 1 590336 models.common.Conv [256, 256, 3, 2]
93 [-1, -3, 51] 1 0 models.common.Concat [1]
94 -1 1 525312 models.common.Conv [1024, 512, 1, 1]
95 -2 1 525312 models.common.Conv [1024, 512, 1, 1]
96 -1 1 1180160 models.common.Conv [512, 256, 3, 1]
97 -1 1 590336 models.common.Conv [256, 256, 3, 1]
98 -1 1 590336 models.common.Conv [256, 256, 3, 1]
99 -1 1 590336 models.common.Conv [256, 256, 3, 1]
100[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1]
101 -1 1 1049600 models.common.Conv [2048, 512, 1, 1]
102 75 1 328704 models.common.RepConv [128, 256, 3, 1]
103 88 1 1312768 models.common.RepConv [256, 512, 3, 1]
104 101 1 5246976 models.common.RepConv [512, 1024, 3, 1]
105 [102, 103, 104] 1 190582 models.yolo.IDetect [30, [[12, 16, 19, 36, 40, 28], [36, 75, 76, 55, 72, 146], [142, 110, 192, 243, 459, 401]], [256, 512, 1024]]
[W NNPACK.cpp:53] Could not initialize NNPACK! Reason: Unsupported hardware.
/usr/local/lib/python3.9/dist-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3190.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
Model Summary: 415 layers, 37352982 parameters, 37352982 gradients, 105.6 GFLOPS
Transferred 557/566 items from yolov7_training.pt
Scaled weight_decay = 0.0005
Optimizer groups: 95 .bias, 95 conv.weight, 98 other
train: Scanning 'PlantDoc-1/train/labels.cache' images and labels... 2328 found,
val: Scanning 'PlantDoc-1/valid/labels.cache' images and labels... 239 found, 0
autoanchor: Analyzing anchors... anchors/target = 5.21, Best Possible Recall (BPR) = 0.9999
Image sizes 416 train, 416 test
Using 8 dataloader workers
Logging results to runs/train/exp6
Starting training for 100 epochs...
Epoch gpu_mem box obj cls total labels img_size
0/99 4.64G 0.06421 0.01904 0.04957 0.1328 61 416
Class Images Labels P R mAP@.5
all 239 454 0.0115 0.184 0.0137 0.00574
Epoch gpu_mem box obj cls total labels img_size
1/99 4.97G 0.04553 0.02114 0.0471 0.1138 71 416
Class Images Labels P R mAP@.5
all 239 454 0.0289 0.37 0.0406 0.0237
Epoch gpu_mem box obj cls total labels img_size
2/99 4.97G 0.04074 0.02138 0.04613 0.1083 54 416
Class Images Labels P R mAP@.5
all 239 454 0.0324 0.429 0.0617 0.0389
Epoch gpu_mem box obj cls total labels img_size
3/99 4.97G 0.03998 0.02033 0.04495 0.1053 73 416
Class Images Labels P R mAP@.5
all 239 454 0.0493 0.323 0.109 0.0719
Epoch gpu_mem box obj cls total labels img_size
4/99 4.97G 0.03724 0.02026 0.0421 0.0996 33 416
Class Images Labels P R mAP@.5
all 239 454 0.124 0.325 0.17 0.126
Epoch gpu_mem box obj cls total labels img_size
5/99 4.97G 0.03523 0.02093 0.03929 0.09545 61 416
Class Images Labels P R mAP@.5
all 239 454 0.134 0.477 0.198 0.149
Epoch gpu_mem box obj cls total labels img_size
6/99 4.97G 0.03424 0.02072 0.03674 0.0917 72 416
Class Images Labels P R mAP@.5
all 239 454 0.553 0.315 0.244 0.18
Epoch gpu_mem box obj cls total labels img_size
7/99 4.97G 0.0337 0.02075 0.03487 0.08933 86 416
Class Images Labels P R mAP@.5
all 239 454 0.325 0.395 0.236 0.174
Epoch gpu_mem box obj cls total labels img_size
8/99 4.97G 0.03275 0.02082 0.03397 0.08753 76 416
Class Images Labels P R mAP@.5
all 239 454 0.414 0.284 0.229 0.167
Epoch gpu_mem box obj cls total labels img_size
9/99 4.97G 0.03262 0.02046 0.03244 0.08552 108 416
Class Images Labels P R mAP@.5
all 239 454 0.379 0.46 0.353 0.26
Epoch gpu_mem box obj cls total labels img_size
10/99 4.97G 0.03194 0.02021 0.03081 0.08295 67 416
Class Images Labels P R mAP@.5
all 239 454 0.322 0.503 0.349 0.268
Epoch gpu_mem box obj cls total labels img_size
11/99 4.97G 0.03222 0.01998 0.03008 0.08228 74 416
Class Images Labels P R mAP@.5
all 239 454 0.421 0.44 0.411 0.311
Epoch gpu_mem box obj cls total labels img_size
12/99 4.97G 0.03218 0.02026 0.02878 0.08122 87 416
Class Images Labels P R mAP@.5
all 239 454 0.334 0.532 0.434 0.328
Epoch gpu_mem box obj cls total labels img_size
13/99 4.97G 0.03162 0.02015 0.02776 0.07953 88 416
Class Images Labels P R mAP@.5
all 239 454 0.63 0.41 0.476 0.361
Epoch gpu_mem box obj cls total labels img_size
14/99 4.97G 0.03211 0.02049 0.02765 0.08025 90 416
Class Images Labels P R mAP@.5
all 239 454 0.38 0.533 0.465 0.35
Epoch gpu_mem box obj cls total labels img_size
15/99 4.97G 0.03118 0.02008 0.0265 0.07776 117 416
Class Images Labels P R mAP@.5
all 239 454 0.336 0.563 0.474 0.354
Epoch gpu_mem box obj cls total labels img_size
16/99 4.97G 0.03136 0.01962 0.0265 0.07748 91 416
Class Images Labels P R mAP@.5
all 239 454 0.369 0.545 0.48 0.367
Epoch gpu_mem box obj cls total labels img_size
17/99 4.97G 0.03102 0.01959 0.025 0.07561 70 416
Class Images Labels P R mAP@.5
all 239 454 0.361 0.536 0.465 0.35
Epoch gpu_mem box obj cls total labels img_size
18/99 4.97G 0.03152 0.01953 0.0249 0.07595 57 416
Class Images Labels P R mAP@.5
all 239 454 0.456 0.527 0.502 0.385
Epoch gpu_mem box obj cls total labels img_size
19/99 4.97G 0.0312 0.01968 0.02414 0.07501 66 416
Class Images Labels P R mAP@.5
all 239 454 0.368 0.593 0.51 0.391
Epoch gpu_mem box obj cls total labels img_size
20/99 4.97G 0.03097 0.01958 0.02396 0.07452 95 416
Class Images Labels P R mAP@.5
all 239 454 0.345 0.506 0.483 0.37
Epoch gpu_mem box obj cls total labels img_size
21/99 4.98G 0.03093 0.0195 0.02428 0.07471 75 416
Class Images Labels P R mAP@.5
all 239 454 0.375 0.532 0.493 0.372
Epoch gpu_mem box obj cls total labels img_size
22/99 4.98G 0.03077 0.01936 0.02306 0.07319 69 416
Class Images Labels P R mAP@.5
all 239 454 0.503 0.461 0.494 0.383
Epoch gpu_mem box obj cls total labels img_size
23/99 4.98G 0.03092 0.01961 0.02271 0.07324 125 416
Class Images Labels P R mAP@.5
all 239 454 0.385 0.567 0.51 0.398
Epoch gpu_mem box obj cls total labels img_size
24/99 4.98G 0.03044 0.01904 0.02226 0.07174 100 416
Class Images Labels P R mAP@.5
all 239 454 0.41 0.638 0.558 0.44
Epoch gpu_mem box obj cls total labels img_size
25/99 4.98G 0.03061 0.01914 0.02246 0.07221 101 416
Class Images Labels P R mAP@.5
all 239 454 0.426 0.564 0.53 0.407
Epoch gpu_mem box obj cls total labels img_size
26/99 4.98G 0.03013 0.01893 0.02176 0.07083 63 416
Class Images Labels P R mAP@.5
all 239 454 0.531 0.549 0.543 0.413
Epoch gpu_mem box obj cls total labels img_size
27/99 4.98G 0.03034 0.01901 0.02076 0.07011 42 416
Class Images Labels P R mAP@.5
all 239 454 0.511 0.598 0.569 0.436
Epoch gpu_mem box obj cls total labels img_size
28/99 4.98G 0.03015 0.01895 0.02043 0.06953 60 416
Class Images Labels P R mAP@.5
all 239 454 0.51 0.529 0.553 0.425
Epoch gpu_mem box obj cls total labels img_size
29/99 4.98G 0.02996 0.01846 0.0208 0.06921 66 416
Class Images Labels P R mAP@.5
all 239 454 0.487 0.585 0.592 0.454
Epoch gpu_mem box obj cls total labels img_size
30/99 4.98G 0.03018 0.01946 0.01951 0.06915 83 416
Class Images Labels P R mAP@.5
all 239 454 0.54 0.492 0.541 0.414
Epoch gpu_mem box obj cls total labels img_size
31/99 4.98G 0.02973 0.01874 0.0196 0.06807 106 416
Class Images Labels P R mAP@.5
all 239 454 0.514 0.557 0.547 0.427
Epoch gpu_mem box obj cls total labels img_size
32/99 4.98G 0.02985 0.01928 0.01942 0.06855 71 416
Class Images Labels P R mAP@.5
all 239 454 0.507 0.614 0.584 0.46
Epoch gpu_mem box obj cls total labels img_size
33/99 4.98G 0.0298 0.0188 0.01917 0.06777 68 416
Class Images Labels P R mAP@.5
all 239 454 0.522 0.591 0.581 0.446
Epoch gpu_mem box obj cls total labels img_size
34/99 4.98G 0.02993 0.01878 0.01936 0.06807 89 416
Class Images Labels P R mAP@.5
all 239 454 0.544 0.533 0.557 0.432
Epoch gpu_mem box obj cls total labels img_size
35/99 4.98G 0.02967 0.01875 0.01843 0.06685 56 416
Class Images Labels P R mAP@.5
all 239 454 0.481 0.581 0.57 0.435
Epoch gpu_mem box obj cls total labels img_size
36/99 4.98G 0.02953 0.01842 0.01843 0.06637 104 416
Class Images Labels P R mAP@.5
all 239 454 0.466 0.65 0.605 0.467
Epoch gpu_mem box obj cls total labels img_size
37/99 4.98G 0.02944 0.01844 0.01839 0.06628 73 416
Class Images Labels P R mAP@.5
all 239 454 0.507 0.636 0.608 0.469
Epoch gpu_mem box obj cls total labels img_size
38/99 4.98G 0.02936 0.01813 0.01711 0.0646 51 416
Class Images Labels P R mAP@.5
all 239 454 0.482 0.65 0.601 0.47
Epoch gpu_mem box obj cls total labels img_size
39/99 4.98G 0.02946 0.01883 0.01784 0.06613 99 416
Class Images Labels P R mAP@.5
all 239 454 0.538 0.627 0.615 0.484
Epoch gpu_mem box obj cls total labels img_size
40/99 4.98G 0.02903 0.01845 0.01712 0.06459 101 416
Class Images Labels P R mAP@.5
all 239 454 0.444 0.663 0.582 0.453
Epoch gpu_mem box obj cls total labels img_size
41/99 4.98G 0.02866 0.01851 0.01667 0.06384 88 416
Class Images Labels P R mAP@.5
all 239 454 0.555 0.614 0.608 0.47
Epoch gpu_mem box obj cls total labels img_size
42/99 4.98G 0.02888 0.01806 0.0169 0.06385 88 416
Class Images Labels P R mAP@.5
all 239 454 0.477 0.596 0.585 0.457
Epoch gpu_mem box obj cls total labels img_size
43/99 4.98G 0.02938 0.01839 0.01706 0.06483 40 416
Class Images Labels P R mAP@.5
all 239 454 0.506 0.619 0.603 0.471
Epoch gpu_mem box obj cls total labels img_size
44/99 4.98G 0.02904 0.01821 0.01653 0.06378 84 416
Class Images Labels P R mAP@.5
all 239 454 0.561 0.6 0.617 0.484
Epoch gpu_mem box obj cls total labels img_size
45/99 4.98G 0.02884 0.01831 0.01603 0.06318 48 416
Class Images Labels P R mAP@.5
all 239 454 0.563 0.557 0.615 0.48
Epoch gpu_mem box obj cls total labels img_size
46/99 4.98G 0.02867 0.01808 0.01549 0.06224 52 416
Class Images Labels P R mAP@.5
all 239 454 0.55 0.596 0.632 0.489
Epoch gpu_mem box obj cls total labels img_size
47/99 4.98G 0.02818 0.01767 0.01471 0.06056 83 416
Class Images Labels P R mAP@.5
all 239 454 0.579 0.642 0.645 0.5
Epoch gpu_mem box obj cls total labels img_size
48/99 4.98G 0.02841 0.01743 0.01517 0.06101 122 416
Class Images Labels P R mAP@.5
all 239 454 0.527 0.645 0.607 0.471
Epoch gpu_mem box obj cls total labels img_size
49/99 4.98G 0.02815 0.01754 0.01513 0.06081 82 416
Class Images Labels P R mAP@.5
all 239 454 0.559 0.64 0.651 0.51
Epoch gpu_mem box obj cls total labels img_size
50/99 4.98G 0.02807 0.01747 0.01477 0.0603 78 416
Class Images Labels P R mAP@.5
all 239 454 0.616 0.616 0.625 0.493
Epoch gpu_mem box obj cls total labels img_size
51/99 4.98G 0.0283 0.01777 0.0144 0.06047 75 416
Class Images Labels P R mAP@.5
all 239 454 0.599 0.587 0.633 0.498
Epoch gpu_mem box obj cls total labels img_size
52/99 4.98G 0.02787 0.01774 0.01441 0.06002 83 416
Class Images Labels P R mAP@.5
all 239 454 0.568 0.636 0.629 0.493
Epoch gpu_mem box obj cls total labels img_size
53/99 4.98G 0.02753 0.01744 0.01347 0.05844 107 416
Class Images Labels P R mAP@.5
all 239 454 0.529 0.658 0.633 0.496
Epoch gpu_mem box obj cls total labels img_size
54/99 4.98G 0.02757 0.01772 0.01359 0.05887 74 416
Class Images Labels P R mAP@.5
all 239 454 0.575 0.66 0.658 0.521
Epoch gpu_mem box obj cls total labels img_size
55/99 4.98G 0.02771 0.01757 0.01353 0.0588 85 416
Class Images Labels P R mAP@.5
all 239 454 0.551 0.63 0.607 0.476
Epoch gpu_mem box obj cls total labels img_size
56/99 4.98G 0.02715 0.01703 0.01277 0.05695 78 416
Class Images Labels P R mAP@.5
all 239 454 0.617 0.566 0.611 0.479
Epoch gpu_mem box obj cls total labels img_size
57/99 4.98G 0.02754 0.01674 0.01294 0.05722 132 416
Class Images Labels P R mAP@.5
all 239 454 0.519 0.638 0.62 0.494
Epoch gpu_mem box obj cls total labels img_size
58/99 4.98G 0.02722 0.0172 0.01293 0.05734 92 416
Class Images Labels P R mAP@.5
all 239 454 0.587 0.614 0.646 0.505
Epoch gpu_mem box obj cls total labels img_size
59/99 4.98G 0.02696 0.01712 0.01286 0.05695 50 416
Class Images Labels P R mAP@.5
all 239 454 0.616 0.643 0.647 0.511
Epoch gpu_mem box obj cls total labels img_size
60/99 4.98G 0.02703 0.01715 0.01219 0.05637 45 416
Class Images Labels P R mAP@.5
all 239 454 0.513 0.674 0.63 0.497
Epoch gpu_mem box obj cls total labels img_size
61/99 4.98G 0.02727 0.01651 0.0126 0.05639 78 416
Class Images Labels P R mAP@.5
all 239 454 0.529 0.68 0.639 0.504
Epoch gpu_mem box obj cls total labels img_size
62/99 4.98G 0.0267 0.01658 0.01185 0.05513 53 416
Class Images Labels P R mAP@.5
all 239 454 0.607 0.636 0.633 0.505
Epoch gpu_mem box obj cls total labels img_size
63/99 4.98G 0.02686 0.01645 0.01174 0.05505 109 416
Class Images Labels P R mAP@.5
all 239 454 0.584 0.602 0.632 0.501
Epoch gpu_mem box obj cls total labels img_size
64/99 4.98G 0.0273 0.01691 0.01198 0.05619 57 416
Class Images Labels P R mAP@.5
all 239 454 0.644 0.59 0.645 0.51
Epoch gpu_mem box obj cls total labels img_size
65/99 4.98G 0.0268 0.01623 0.0122 0.05523 57 416
Class Images Labels P R mAP@.5
all 239 454 0.608 0.604 0.632 0.502
Epoch gpu_mem box obj cls total labels img_size
66/99 4.98G 0.0264 0.0168 0.01159 0.05478 61 416
Class Images Labels P R mAP@.5
all 239 454 0.552 0.67 0.644 0.508
Epoch gpu_mem box obj cls total labels img_size
67/99 4.98G 0.02643 0.01643 0.01131 0.05417 71 416
Class Images Labels P R mAP@.5
all 239 454 0.571 0.698 0.654 0.516
Epoch gpu_mem box obj cls total labels img_size
68/99 4.98G 0.02637 0.01625 0.01148 0.0541 59 416
Class Images Labels P R mAP@.5
all 239 454 0.548 0.698 0.648 0.516
Epoch gpu_mem box obj cls total labels img_size
69/99 4.98G 0.02611 0.01567 0.01095 0.05274 38 416
Class Images Labels P R mAP@.5
all 239 454 0.55 0.665 0.647 0.513
Epoch gpu_mem box obj cls total labels img_size
70/99 4.98G 0.02625 0.0157 0.01042 0.05237 86 416
Class Images Labels P R mAP@.5
all 239 454 0.578 0.618 0.64 0.512
Epoch gpu_mem box obj cls total labels img_size
71/99 4.98G 0.02604 0.01553 0.01127 0.05284 76 416
Class Images Labels P R mAP@.5
all 239 454 0.571 0.685 0.658 0.519
Epoch gpu_mem box obj cls total labels img_size
72/99 4.98G 0.02641 0.0158 0.01048 0.05268 84 416
Class Images Labels P R mAP@.5
all 239 454 0.614 0.624 0.661 0.523
Epoch gpu_mem box obj cls total labels img_size
73/99 4.98G 0.02614 0.0159 0.01026 0.0523 137 416
Class Images Labels P R mAP@.5
all 239 454 0.611 0.644 0.651 0.519
Epoch gpu_mem box obj cls total labels img_size
74/99 4.98G 0.02606 0.01574 0.01023 0.05203 61 416
Class Images Labels P R mAP@.5
all 239 454 0.588 0.679 0.657 0.522
Epoch gpu_mem box obj cls total labels img_size
75/99 4.98G 0.02545 0.01556 0.009982 0.05099 55 416
Class Images Labels P R mAP@.5
all 239 454 0.59 0.688 0.642 0.512
Epoch gpu_mem box obj cls total labels img_size
76/99 4.98G 0.02564 0.01534 0.01026 0.05124 73 416
Class Images Labels P R mAP@.5
all 239 454 0.595 0.652 0.646 0.517
Epoch gpu_mem box obj cls total labels img_size
77/99 4.98G 0.02555 0.0155 0.009653 0.0507 70 416
Class Images Labels P R mAP@.5
all 239 454 0.586 0.659 0.657 0.524
Epoch gpu_mem box obj cls total labels img_size
78/99 4.98G 0.0257 0.01524 0.009516 0.05045 95 416
Class Images Labels P R mAP@.5
all 239 454 0.593 0.638 0.662 0.53
Epoch gpu_mem box obj cls total labels img_size
79/99 4.98G 0.0258 0.01546 0.009779 0.05103 53 416
Class Images Labels P R mAP@.5
all 239 454 0.653 0.629 0.658 0.521
Epoch gpu_mem box obj cls total labels img_size
80/99 4.98G 0.02583 0.01557 0.009759 0.05116 77 416
Class Images Labels P R mAP@.5
all 239 454 0.627 0.665 0.675 0.534
Epoch gpu_mem box obj cls total labels img_size
81/99 4.98G 0.0255 0.01522 0.009091 0.04981 47 416
Class Images Labels P R mAP@.5
all 239 454 0.591 0.637 0.663 0.531
Epoch gpu_mem box obj cls total labels img_size
82/99 4.98G 0.02542 0.01509 0.009015 0.04952 91 416
Class Images Labels P R mAP@.5
all 239 454 0.58 0.672 0.64 0.511
Epoch gpu_mem box obj cls total labels img_size
83/99 4.98G 0.0254 0.01526 0.008759 0.04942 99 416
Class Images Labels P R mAP@.5
all 239 454 0.608 0.639 0.656 0.522
Epoch gpu_mem box obj cls total labels img_size
84/99 4.98G 0.02527 0.01486 0.00905 0.04918 57 416
Class Images Labels P R mAP@.5
all 239 454 0.688 0.607 0.671 0.538
Epoch gpu_mem box obj cls total labels img_size
85/99 4.98G 0.02534 0.01527 0.008806 0.04942 88 416
Class Images Labels P R mAP@.5
all 239 454 0.626 0.624 0.657 0.523
Epoch gpu_mem box obj cls total labels img_size
86/99 4.98G 0.02515 0.01517 0.008958 0.04927 80 416
Class Images Labels P R mAP@.5
all 239 454 0.656 0.637 0.661 0.528
Epoch gpu_mem box obj cls total labels img_size
87/99 4.98G 0.02501 0.01487 0.008332 0.04821 93 416
Class Images Labels P R mAP@.5
all 239 454 0.597 0.691 0.678 0.539
Epoch gpu_mem box obj cls total labels img_size
88/99 4.98G 0.02466 0.01471 0.007957 0.04733 81 416
Class Images Labels P R mAP@.5
all 239 454 0.591 0.675 0.664 0.529
Epoch gpu_mem box obj cls total labels img_size
89/99 4.98G 0.02516 0.01473 0.008415 0.04831 60 416
Class Images Labels P R mAP@.5
all 239 454 0.596 0.676 0.667 0.531
Epoch gpu_mem box obj cls total labels img_size
90/99 4.98G 0.0248 0.01488 0.008268 0.04795 78 416
Class Images Labels P R mAP@.5
all 239 454 0.616 0.663 0.668 0.535
Epoch gpu_mem box obj cls total labels img_size
91/99 4.98G 0.02454 0.01452 0.008167 0.04723 53 416
Class Images Labels P R mAP@.5
all 239 454 0.635 0.622 0.673 0.536
Epoch gpu_mem box obj cls total labels img_size
92/99 4.98G 0.0246 0.01464 0.007923 0.04716 81 416
Class Images Labels P R mAP@.5
all 239 454 0.638 0.641 0.658 0.527
Epoch gpu_mem box obj cls total labels img_size
93/99 4.98G 0.02497 0.01503 0.00849 0.04849 88 416
Class Images Labels P R mAP@.5
all 239 454 0.659 0.648 0.666 0.53
Epoch gpu_mem box obj cls total labels img_size
94/99 4.98G 0.02465 0.01441 0.007869 0.04692 73 416
Class Images Labels P R mAP@.5
all 239 454 0.597 0.685 0.665 0.535
Epoch gpu_mem box obj cls total labels img_size
95/99 4.98G 0.02465 0.01454 0.007819 0.04701 102 416
Class Images Labels P R mAP@.5
all 239 454 0.645 0.641 0.664 0.531
Epoch gpu_mem box obj cls total labels img_size
96/99 4.98G 0.02456 0.01456 0.007777 0.0469 45 416
Class Images Labels P R mAP@.5
all 239 454 0.628 0.64 0.666 0.531
Epoch gpu_mem box obj cls total labels img_size
97/99 4.98G 0.02481 0.01469 0.007886 0.04739 75 416
Class Images Labels P R mAP@.5
all 239 454 0.6 0.676 0.677 0.542
Epoch gpu_mem box obj cls total labels img_size
98/99 4.98G 0.02451 0.0143 0.007577 0.04638 80 416
Class Images Labels P R mAP@.5
all 239 454 0.618 0.669 0.658 0.524
Epoch gpu_mem box obj cls total labels img_size
99/99 4.98G 0.0246 0.01457 0.007506 0.04668 91 416
Class Images Labels P R mAP@.5
all 239 454 0.631 0.657 0.668 0.536
Apple Scab Leaf 239 13 0.605 0.846 0.776 0.643
Apple leaf 239 10 0.467 0.7 0.562 0.42
Apple rust leaf 239 11 0.772 0.727 0.766 0.623
Bell_pepper leaf spot 239 11 0.486 0.818 0.667 0.561
Bell_pepper leaf 239 15 0.395 0.4 0.386 0.307
Blueberry leaf 239 22 0.902 0.773 0.886 0.669
Cherry leaf 239 19 0.858 0.636 0.785 0.61
Corn Gray leaf spot 239 4 0.313 0.5 0.319 0.238
Corn leaf blight 239 12 0.664 0.667 0.843 0.769
Corn rust leaf 239 10 0.924 0.9 0.973 0.827
Peach leaf 239 10 0.832 0.991 0.962 0.765
Potato leaf late blight 239 17 0.446 0.588 0.492 0.396
Potato leaf 239 10 0.0758 0.1 0.129 0.123
Raspberry leaf 239 17 0.751 1 0.973 0.85
Soyabean leaf 239 20 0.801 0.65 0.748 0.659
Squash Powdery mildew leaf 239 8 0.636 0.875 0.813 0.741
Strawberry leaf 239 30 0.963 1 0.996 0.857
Tomato Early blight leaf 239 19 0.408 0.364 0.325 0.253
Tomato Septoria leaf spot 239 24 0.491 0.75 0.66 0.449
Tomato leaf bacterial spot 239 27 0.551 0.296 0.364 0.241
Tomato leaf late blight 239 14 0.375 0.429 0.332 0.249
Tomato leaf mosaic virus 239 14 0.478 0.643 0.65 0.516
Tomato leaf yellow virus 239 36 0.894 0.234 0.542 0.362
Tomato leaf 239 42 0.706 0.738 0.779 0.39
Tomato mold leaf 239 16 0.536 0.362 0.408 0.289
grape leaf black rot 239 15 0.831 0.867 0.914 0.81
grape leaf 239 8 0.876 0.885 0.982 0.845
100 epochs completed in 0.942 hours.
Optimizer stripped from runs/train/exp6/weights/last.pt, 75.1MB
Optimizer stripped from runs/train/exp6/weights/best.pt, 75.1MB
Evaluation
We pass a number of arguments to the evaluation scripts: - weights: the best weights after custom training on the PlantDoc dataset - conf: confidence threshold - source: the validation images - img_size: image size
# Run evaluation
! python detect.py --weights runs/train/exp6/weights/best.pt --conf 0.1 --source {dataset.location}/valid/images --img-size 416
We show 5*5 images from the validation data, and the disease detection results of these images, to visualize the performance of YOLOv7
import os
from PIL import Image
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
root_dir = dataset.location + '/valid/images/'
img_paths = [os.path.join(root_dir, img_name) for img_name in os.listdir(root_dir)]
fig = plt.figure(figsize=(20,20))
grid = ImageGrid(fig, 111, # similar to subplot(111)
nrows_ncols=(5,5),
axes_pad=0.1
)
for ax, img_path in zip(grid, img_paths):
img = Image.open(img_path)
ax.axis('off')
ax.imshow(img)
root_dir = "/notebooks/yolov7/runs/detect/exp3/"
img_paths = [os.path.join(root_dir, img_name) for img_name in os.listdir(root_dir)]
fig = plt.figure(figsize=(20,20))
grid = ImageGrid(fig, 111, # similar to subplot(111)
nrows_ncols=(5,5),
axes_pad=0.1
)
for ax, img_path in zip(grid, img_paths):
img = Image.open(img_path)
ax.axis('off')
ax.imshow(img)